package view;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import controller.IController;

/*
 * 
 * UserInputListener class
 * 
 * Implements the KeyListener interface. Detects any keyboard input and passes
 * the keycode along to the model for evaluation.
 * 
 */

public class UserInputListener implements KeyListener {

	private IController controller;

	/**
	 * UserInputListener
	 * 
	 * creates theUserInputListener using the controller that is passed in
	 * 
	 * @param c
	 */
	public UserInputListener(IController c) {
		this.controller = c;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
	 */
	@Override
	public void keyPressed(KeyEvent e) {
		int key = e.getKeyCode();
		controller.evaluateKeyPressed(key);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
	 */
	@Override
	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();
		controller.evaluateKeyReleased(key);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
	 */
	@Override
	public void keyTyped(KeyEvent e) {
		return;
	}
}
